package com.hnust.root.web.controller.forward.user;

import com.hnust.root.common.base.response.BaseRestController;
import com.hnust.root.common.base.response.BaseResult;
import com.hnust.root.common.model.MapData;
import com.hnust.root.service.impl.forward.wx.MapDataService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/api/user")
public class MapDataController extends BaseRestController {
    @Autowired
    private MapDataService mapDataService;

    @ApiOperation("获取地图数据->省份名称及对应的人数")
    @GetMapping("/getMapData")
    public BaseResult<List<MapData>> getMapData(@RequestParam("university") String university) {
        List<MapData> mapDataList = mapDataService.getMapDataByUniversity(university);
        return fillSuccessData(mapDataList);
    }

    @ApiOperation("获取地图数据->获取与当前用户相同地区的人数")
    @GetMapping("/getUserAndLocation")
    public BaseResult<Map<String,Integer>> getUserAndLocation(@RequestParam("university") String university) {
        Map<String, Integer> map = mapDataService.getUserAndCityCount(university);
        return fillSuccessData(map);
    }


}
